// 解题思路：
// 核心是归并排序并去重，去重的方法就是：
// 当两个集合当前位置的元素值相同，就让其中一个下标自增
// 当不相同时，打印小的那一个

import java.util.*;
import java.io.*;

public class MergeAndRemoveDuplicates {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];

        for(int i = 0; i < n; i++) a[i] = in.nextInt();
        for(int i = 0; i < m; i++) b[i] = in.nextInt();

        Arrays.sort(a); Arrays.sort(b);

        int cur1 = 0; int cur2 = 0;
        while(cur1 < n && cur2 < m){
            if(a[cur1] == b[cur2]) cur1++;
            else {
                if(a[cur1] < b[cur2]) out.print(a[cur1++] + " ");
                else if(a[cur1] > b[cur2]) out.print(b[cur2++] + " ");
            }
        }
        while(cur1 < n) {
            if(cur1 == n - 1) out.print(a[cur1++]);
            else out.print(a[cur1++] + " ");
        }
        while(cur2 < m) {
            if(cur2 == n - 1) out.print(b[cur2++]);
            else out.print(b[cur2++] + " ");
        }

        out.close();
    }
}
